<?php
namespace app\admin\controller;

class Login extends Base2
{
     public function index()
     {
        return view();
     }

    /**
     * 退出登陆
     */
    public function logout()
    {
        session(null);
        $this->redirect('login/index');
    }

    /**
     * 登陆处理
     * @return \think\response\Json
     */
    public function login()
    {
        $account = I('post.user_name');
        $password = I('post.password');
        if (!$account||!$password){
            return $this->param_error();
        }
        $user = D('account');
        $where['enable']=0;
        $where['account']=$account;
        $where['passwd']=md5(md5($password).config("keys"));
        $res = $user->where($where)->find();
        if(!$res){
            return $this->returnAlert("用户名或密码错误");
        }
        session("jcuserId",$res['id']);
        return $this->returnOk();
    }
}